package com.android.pagemarket.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.pagemarket.R;
import com.android.pagemarket.business.model.PaperType;

/*********************************************************
 * @author : Administrator
 * @version : 2012-11-8
 * @see : TODO
 * @Copyright : copyrights reserved by personal 2007-2011
 **********************************************************/
public class PaperTypeItemView extends LinearLayout
{
    private TextView name;
    private ImageView img;
    
    public PaperTypeItemView(Context context)
    {
        super(context);
    }
    
    public PaperTypeItemView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate()
    {
        super.onFinishInflate();
        name = (TextView)findViewById(R.id.name);
        img  = (ImageView)findViewById(R.id.img);
    }
    
    public void bindData(PaperType data)
    {
        this.name.setText(data.paperName);
        setChecked(data.isChecked);
    }

    public void setChecked(boolean checked)
    {
        setBackgroundResource(checked ?  R.drawable.bg_papertype_selected : R.drawable.transparent_bg);
        name.setTextColor(getResources().getColor(checked ? R.color.paper_type_selected_color : R.color.paper_type_nomarl_color));
        img.setVisibility(checked ? View.GONE : View.VISIBLE);
    }
}
